package com.bbs.resp;

import lombok.Data;
import org.springframework.http.HttpStatus;

import java.io.Serializable;

@Data
public class Result implements Serializable {

    private Boolean success;

    private HttpStatus code;

    private String message;

    private Object data;

    public Result(boolean success, HttpStatus code, Object data) {
        this.success = success;
        this.code = code;
        this.message = "";
        this.data = data;
    }

    public static Result of(ErrorView rc,Object data){

        return new Result(rc,data);
    }

    @Deprecated
    public Result() {

    }

    public Result(Boolean success, HttpStatus code, String message, Object data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result(ErrorView rc, Object data) {
        this.success = rc.success;
        this.code = rc.code;
        this.message = rc.message;
        this.data = data;
    }

    public static Result of(boolean success, HttpStatus code, Object data) {
        return new Result(success,code,data);
    }
}
